﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace dzs.Web.distribution
{
    public partial class Modify : Web.Admin.BasePage
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int did = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(did);
                }
            }
        }

        private void ShowInfo(int did)
        {
            dzs.BLL.distribution bll = new dzs.BLL.distribution();
            dzs.Model.distribution model = bll.GetModel(did);
            this.txtdnum.Text = model.dnum.ToString();
            ddlsta.SelectedValue = model.reqstate.ToString();
            this.txtreqdate.Text = model.reqdate.Value.ToLongDateString();
            this.txtdbatch.Text = model.dbatch;
            this.txthandling.Text = model.handling;
            this.txtcharges.Text = model.charges.ToString();
            this.txtlinkman.Text = model.linkman;
            this.txtlinkway.Text = model.linkway;
            this.txthandmode.Text = model.handmode;

        }

        public void btnSave_Click(object sender, EventArgs e)
        {
            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                int did = (Convert.ToInt32(Request.Params["id"]));                
                decimal dnum = decimal.Parse(this.txtdnum.Text);
                int reqstate = int.Parse(ddlsta.SelectedValue);
                DateTime reqdate = DateTime.Parse(this.txtreqdate.Text);
                string dbatch = this.txtdbatch.Text;
                string handling = this.txthandling.Text;
                decimal charges = decimal.Parse(this.txtcharges.Text);
                string linkman = this.txtlinkman.Text;
                string linkway = this.txtlinkway.Text;
                string handmode = this.txthandmode.Text;
                dzs.Model.distribution model = new dzs.Model.distribution();
                model.did = did;
                model.dnum = dnum;
                model.reqstate = reqstate;
                model.reqdate = reqdate;
                model.dbatch = dbatch;
                model.handling = handling;
                model.charges = charges;
                model.linkman = linkman;
                model.linkway = linkway;
                model.handmode = handmode;
                dzs.BLL.distribution bll = new dzs.BLL.distribution();
                bll.Updatedis(model);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "list.aspx");
            }
        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
